﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Warehouse_Bar_Code
{
    public class DBH
    {
        //通用连接
        static string str = "server=.;database=Storage;Integrated security=true;";
        static SqlConnection conn = new SqlConnection(str);

        //断开式查询
        public static DataTable Select(string sql)
        {
            SqlDataAdapter sda = new SqlDataAdapter(sql, conn);
            DataSet ds = new DataSet();
            sda.Fill(ds);
            return ds.Tables[0];
        }

        //增删改
        public static int NoSelect(string sql)
        {
            conn.Open();
            SqlCommand comm = new SqlCommand(sql, conn);
            int num = comm.ExecuteNonQuery();
            conn.Close();
            return num;
        }

    }
}
